(* Copyright (c) 2018-2024 by Kithara Software GmbH. All rights reserved. *)

//##############################################################################################################
//
// File:         NetworkUdpSend_inc.pas
//
// Used Modules: Network Module
//
// Description:  Shared definitions between user space application and kernel space DLL for example of
//               how to implement a UDP sender
//
// Creator:      a.thi 2018-12-21
//
//##############################################################################################################

   {======================================================================*\
   |                    *** DISCLAIMER OF WARRANTY ***                     |
   |                                                                       |
   |       THIS  CODE AND INFORMATION IS PROVIDED 'AS IS'  WITHOUT         |
   |       A  WARRANTY OF  ANY KIND, EITHER  EXPRESSED OR  IMPLIED,        |
   |       INCLUDING  BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF         |
   |       MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE.        |
   \*======================================================================}

//##############################################################################################################
//
// Purpose:
//
// This example shows how to send UDP datagrams.
//
// First we open the network adapter and create a socket.
// Then we send incoming keyboard characters to a target socket.
//
// This sample is designed to be the counterpart to the sample NetworkUdpReceive.
//
// PLEASE SPECIFY YOUR IP-ADDRESS, SUBNET-MASK AND GATEWAY-IP-ADDRESS IN THE KS_makeIPv4() CALLS AS WELL AS
// THE RECEIVER IP-ADRESS AND PORT IN THE APPLICATION PROGRAMM BEFORE RUNNING THIS EXAMPLE!
//
//##############################################################################################################

//--------------------------------------------------------------------------------------------------------------
// NetworkUdpSend_inc
//--------------------------------------------------------------------------------------------------------------

unit NetworkUdpSend_inc;

{$H+}


//--------------------------------------------------------------------------------------------------------------
// Interface
//--------------------------------------------------------------------------------------------------------------

interface

uses
  KrtsDemo;

type


//--------------------------------------------------------------------------------------------------------------
// SharedData is a user defined record for information exchange using shared memory between the
// kernel space DLL and the user space application.
// You are free to define your own system bitsize independent arguments in any record.
//--------------------------------------------------------------------------------------------------------------

  SharedData = packed record
    hKernel     : KSHandle;                             // Handle of the kernel
    hAdapter    : KSHandle;                             // Handle of the network adapter
    hSocket     : KSHandle;                             // Handle of the socket
    ipConfig    : KSIPConfig;                           // Address information for the socket
    serverIp    : Uint32;                               // IP Address of the target to connect to
    udpPort     : Int32;                                // Port of the target to connect to
    pDeviceName : array[0..255] of AnsiChar;            // Name of the network adapter

    pSendBuffer : array[0..255] of AnsiChar;            // Buffer containing the text to send through the socket
    sendLength  : Int32;                                // Length of the text within the buffer
  end;
  PSharedData = ^SharedData;


//--------------------------------------------------------------------------------------------------------------
// Implementation
//--------------------------------------------------------------------------------------------------------------

implementation
end.
